package com.mxl.service.cashorder.rule;

import javax.annotation.Resource;

import com.mxl.common.helper.ResponseErrorCode;
import com.mxl.common.rule.AbstractRule;
import com.mxl.dao.cashorder.impl.GatewayPayOrderDaoImpl;
import com.mxl.service.cashorder.dto.CashOrderRequest;

/**
 * 检查商户订单和商户号 提交的订单唯一
 * 
 * @author Administrator
 * 
 */
public class CheckMemberCodeOrderOnly extends AbstractRule {

	@Resource(name = "gatewayPayOrderDao")
	private GatewayPayOrderDaoImpl gatewayPayOrderDao;

	protected boolean makeDecision(Object obj) throws Exception {
		CashOrderRequest c = (CashOrderRequest) obj;
		if (gatewayPayOrderDao.getMemberCodeOrderId(c.getMemberCode(), c
				.getOrderId())) {
			c.setMsgId(ResponseErrorCode.MEMBER_ORDERID_REPEAT.getValue());
			return false;
		}
		return true;
	}

}
